<?php



class formsActions extends sfActions

{

	public function executeIndex()
	{
		$this->forward('forms', 'edit');
	}


	public function executeEdit()
	{
		$cap = new Captcha();
        $this->getUser()->setAttribute('captcha', $cap->generate());
	}



    public function handleErrorSend()
    {
        $this->forward('forms', 'edit');
    }



    public function executeSend()
    {

	    if( $this->getRequest()->getMethod() == sfRequest::POST )
        {
		  sfLoader::loadHelpers('Partial');

          $mail = new sfMail();

          $mail->initialize();

          $mail->addCustomHeader('MIME-Version', '1.0');

          $mail->addCustomHeader('Content-type', 'text/html;charset=utf-8');



          $mail->setCharset('utf-8');



          // definition of the required parameters

          $mail->setSender(sfConfig::get('app_moderator_email'), sfConfig::get('app_moderator_name'));

          $mail->setFrom(sfConfig::get('app_moderator_email'), sfConfig::get('app_moderator_name'));



          $mail->addAddress(sfConfig::get('app_moderator_email'));



          $mail->setSubject(sfConfig::get('app_contact_subject'));

		  $body = get_partial('forms/contact_mail');

          $mail->setBody($body);

          //debugvar($body);

          //die();

          // send the email

          $mail->send();



          $this->setFlash('success', 'Your message was successfully sent');

          $this->redirect('forms/edit');

	    }
        else
        {
          $this->redirect('forms/edit');
        }
    }



}

?>